﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MathQ
{
    public class MathEqua
    {
        private int _X;
        private int _Y;
        private MathOpt _Opt;
        private string _OptTxt;

        public MathEqua()
        {
            int xMax = 10;
            int yMax = 10;
            int xMin = 1;
            int yMin = 1;

            _X = Program._rnd.Next(xMin, xMax + 1);
            //while (_X < 10) _X = Program._rnd.Next(yMin, xMax + 1);

            _Opt = (MathOpt)Program._rnd.Next(0, 2); //Only plus & minus would be selected

            if (_Opt == MathOpt.Plus)
            {
                _OptTxt = "+";
                _Y = Program._rnd.Next(yMin, yMax + 1);
            }
            else if (_Opt == MathOpt.Minus)
            {
                _OptTxt = "-";
                _Y = Program._rnd.Next(yMin, _X);
            }

        }

        public int X
        {
            get { return _X; }
            set { _X = value; }
        }

        public int Y
        {
            get { return _Y; }
            set { _Y = value; }
        }

        public MathOpt Opt
        {
            get { return _Opt; }
            set { _Opt = value; }
        }

        public string OptTxt
        {
            get { return _OptTxt; }
            set { _OptTxt = value; }
        }

        public int Answer
        {
            get 
            {
                int ans;
                if (_Opt == MathOpt.Plus)
                {
                    ans = _X + _Y;
                }
                else if (_Opt == MathOpt.Minus)
                {
                    ans = _X - _Y;
                }
                else if (_Opt == MathOpt.Multi)
                {
                    ans = _X * _Y;
                }
                else
                {
                    ans = _X / _Y;
                }

                return ans; 
            }
        }


    }


}
